package com.demo.deal_service.model.result;

import com.demo.deal_service.enums.ResultEnum;
import org.springframework.http.HttpStatus;

public class ResultEntity<T> {
    private String code;
    private String name;
    private String massage;
    private HttpStatus httpStatus;
    private T data;

    public ResultEntity(ResultEnum resultEnum, T data, String massage) {
        this.code = resultEnum.getCode();
        this.httpStatus = resultEnum.getHttpStatus();
        this.name = resultEnum.getName();
        this.massage = String.format(resultEnum.getMsgPattern(), massage);
        this.data = data;
        this.data = data;
    }

    public ResultEntity(ResultEnum resultEnum, String massage) {
        this(resultEnum, null, massage);
    }

    public ResultEntity(ResultEnum resultEnum, T data) {
        this(resultEnum, data, "");
    }

    public ResultEntity() { }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMassage() {
        return massage;
    }

    public void setMassage(String massage) {
        this.massage = massage;
    }

    public HttpStatus getHttpStatus() {
        return httpStatus;
    }

    public void setHttpStatus(HttpStatus httpStatus) {
        this.httpStatus = httpStatus;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
